package com.cpsdna.bean.user;

import com.cpsdna.bean.firm.Firm;
import org.nutz.dao.entity.annotation.*;

import java.util.Date;

/**
 * Created by Jianghao on 2017/2/27.
 * 用户表
 *
 * @author Howe(howechiang@gmail.com)
 */
@Table("user")
public class User {

    public static final String USER_SESSION_KEY = "024759843c630e3f";

    /**
     * 用户ID
     */
    @Id
    @Column("user_id")
    private Integer userId;

    /**
     * 手机号码
     */
    @Name
    @Column("mobile")
    private String mobile;

    /**
     * 登录密码
     */
    @Column("password")
    private String password;

    /**
     * 用户昵称
     */
    @Column("nick_name")
    private String nickName;

    /**
     * 电子邮箱
     */
    @Column("email")
    private String email;

    /**
     * 加密盐钥
     */
    @Column("salt")
    private String salt;

    /**
     * 用户头像
     */
    @Column("avatar_url")
    private String avatarUrl;

    /**
     * 用户组
     */
    @Column("user_group")
    private String userGroup;

    /**
     * 账户状态
     */
    @Column("account_status")
    private Integer accountStatus;

    /**
     * 注册时间
     */
    @Column("registration_time")
    private Date registrationTime;

    /**
     * 注册IP
     */
    @Column("registration_ip")
    private String registrationIP;

    /**
     * 公司Id
     */
    @Column("firm_id")
    private Integer firmId;

    public Integer getFirmId() {
        return firmId;
    }

    public void setFirmId(Integer firmId) {
        this.firmId = firmId;
    }

    /**
     * 公司信息表
     */
    @One(target = Firm.class, field = "firmId")
    private Firm firm;

    public Firm getFirm() {
        return firm;
    }

    public void setFirm(Firm firm) {
        this.firm = firm;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getRegistrationIP() {
        return registrationIP;
    }

    public void setRegistrationIP(String registrationIP) {
        this.registrationIP = registrationIP;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getUserGroup() {
        return userGroup;
    }

    public void setUserGroup(String userGroup) {
        this.userGroup = userGroup;
    }

    public Integer getAccountStatus() {
        return accountStatus;
    }

    public void setAccountStatus(Integer accountStatus) {
        this.accountStatus = accountStatus;
    }

    public Date getRegistrationTime() {
        return registrationTime;
    }

    public void setRegistrationTime(Date registrationTime) {
        this.registrationTime = registrationTime;
    }

    public User(Integer userId, String mobile, String password, String nickName, String email, String salt, String avatarUrl, String userGroup, Integer accountStatus, Date registrationTime, String registrationIP, Integer firmId) {
        this.userId = userId;
        this.mobile = mobile;
        this.password = password;
        this.nickName = nickName;
        this.email = email;
        this.salt = salt;
        this.avatarUrl = avatarUrl;
        this.userGroup = userGroup;
        this.accountStatus = accountStatus;
        this.registrationTime = registrationTime;
        this.registrationIP = registrationIP;
        this.firmId = firmId;
    }

    public User() { }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", mobile='" + mobile + '\'' +
                ", password='" + password + '\'' +
                ", nickName='" + nickName + '\'' +
                ", email='" + email + '\'' +
                ", salt='" + salt + '\'' +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", userGroup='" + userGroup + '\'' +
                ", accountStatus=" + accountStatus +
                ", registrationTime=" + registrationTime +
                ", registrationIP='" + registrationIP + '\'' +
                ", firmId=" + firmId +
                ", firm=" + firm +
                '}';
    }
}
